<template>
  <div class="content-card">
    <div style="padding-top:10px;">
        <Card :bordered="false" dis-hover>
            <div slot="title">
              <span class="title" style="font-size:16px;">我的收藏</span>
              
            </div>
            <div>
                <div class="check-radio">
                  <Radio-group v-model="radio" type="button" @on-change='checkChange'>
                    <Radio :label='1'>产品</Radio>
                    <Radio :label='2'>资讯</Radio>
                  </Radio-group>
                </div>
            </div>
            <div v-if="product == 1">
              <div class="marginT20" v-for="item in productList" :key="item.productId" style="border-bottom:1px solid #ccc;padding-bottom:20px;">
                <productMsg @receiveBtn='cancelCollectProduct' :proMsg='item' text='取消收藏' button></productMsg>
              </div>
              <div class="marginT20">
                <Row class="marginT20">
                    <i-col span='14' offset='10'>
                        <Page @infoBnt='cancelCollectInfo' :total="productTotal" show-elevator />
                    </i-col>
                </Row> 
              </div>
            </div>
            <div v-if="product == 2" >
              <div  v-for="item in newsList" :key="item.id" class="marginT20" style="border-bottom:1px solid #ccc;padding-bottom:20px;">
                <infoMsg :infoMsg='item' :img='banner' collect button></infoMsg> 
              </div>
              

              <div class="marginT20">
                <Row class="marginT20">
                    <i-col span='14' offset='10'>
                        <Page :total="newsTotal" show-elevator />
                    </i-col>
                </Row> 
              </div>
            </div>
            
        </Card>
    </div>   
  </div>
</template>
<script>
import productMsg from '@/components/productMsg'
import infoMsg from '@/components/infoMsg'
import banner from '@/assets/images/banner.png'
export default {
  data(){
    return{
      radio:1,
      a:'扫今冬阿森纳单买是大',
      product:1,
      banner:banner,
      productList:[],
      newsList:[],
      productTotal:null,
      newsTotal:null
    }
  },
  components:{
    productMsg,
    infoMsg
  },
  mounted(){
    this.getCollectProduct()
    this.getCollectNews()
  },
  methods:{
    getCollectProduct(){
      this.$axios('myCollectgetProduct',[1,10],{
        userPhone:this.$token.getUUID()
      }).then(res=>{
        console.log(res)
        this.productList=res.data.result
        this.productTotal=res.data.listSize
      })
    },
    getCollectNews(){
      this.$axios('myCollectgetInfo',[1,10],{
        userPhone:this.$token.getUUID()
      }).then(res=>{
        console.log(res)
        this.newsList=res.data.result
        this.newsTotal=res.data.listSize
      })
    },
    cancelCollectProduct(productId){
      this.$axios('getProductsdeleteProduct',[productId],{
        userPhone:this.$token.getUUID()
      }).then(res=>{
        console.log(res)
      })
    },
    cancelCollectInfo(id){
      this.$axios('myCollectdeleteInfo',[id],{
        userPhone:this.$token.getUUID()
      }).then(res=>{
        console.log(res)
      })
    },



    checkChange(idx){
      this.product=idx
    }
  }
}
</script>

<style>

</style>